package face.pay.util;

import java.util.HashMap;

/**
 * @Auther: zkj
 * @Date: 2018/11/1 10:23
 * @Description:
 */

public class ResultMessage {


    private static   Integer SUCCESS_CODE =1;

    private static   String SUCCESS_MESSAGE ="操作成功";


    private static   Integer FAIL_CODE =0;

    private static   String FAIL_MESSAGE ="处理失败";


    private static   Integer ERROR_CODE =-1;

    private static   String ERROR_MESSAGE ="服务器内部错误";


    private  Integer code;

    private  Integer errorCode = 0;


    private  String  message;

    private  Object  data =  new HashMap<>();



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public ResultMessage() {

        super();
    }

    public ResultMessage(Integer code) {
        super();
        this.code = code;
    }

    public ResultMessage(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResultMessage(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static  ResultMessage createSuccess(String message) {

        return   new ResultMessage(SUCCESS_CODE,message);

    }


    public static ResultMessage createSuccess(Object data) {

        return   new ResultMessage(SUCCESS_CODE,SUCCESS_MESSAGE,data);

    }

    public static ResultMessage createSuccess(String message,Object data) {

        return   new ResultMessage(SUCCESS_CODE,message,data).setErrorCode(0);

    }

    public static ResultMessage createSuccess() {

        return   new ResultMessage(SUCCESS_CODE,SUCCESS_MESSAGE);

    }


    public static ResultMessage createFail(String message) {

        return   new ResultMessage(FAIL_CODE,message);

    }

    public static ResultMessage createFail(String message,Object data) {

        return   new ResultMessage(FAIL_CODE,message,data);

    }

    public static ResultMessage createFail(Object data) {

        return   new ResultMessage(FAIL_CODE,FAIL_MESSAGE,data);

    }


    public static ResultMessage createError(String message) {

        return   new ResultMessage(ERROR_CODE,message);

    }

    public static ResultMessage createError() {

        return   new ResultMessage(ERROR_CODE,ERROR_MESSAGE);

    }


    public static ResultMessage createFail() {

        return   new ResultMessage(ERROR_CODE,ERROR_MESSAGE);

    }

    public Integer getErrorCode() {
        return errorCode;
    }

    public ResultMessage setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
        return this;
    }
}
